import React, { Component } from 'react'
import Grid from 'components/grid/Grid'
import './HotCate.style.scss'
import {get} from 'api/http'
import {withRouter} from 'react-router-dom'
 class HotCate extends Component {
    constructor(){
        super();
        this.state={
            datalist:[]
        }
    }
    render() {
        return (
            <div className="hotcatiner">
                <h2>热门分类</h2>
                <Grid 
                column={4}
                list={this.state.datalist}
                hasMore={true}
                itemClick={()=>{
                    console.log(1);
                    //跳转到list
                    this.props.history.push('/list')
                }}
                renderTitle={({item})=>{
                    return <span>{item.title}</span>
                }}>
                </Grid>
            </div>
        )
    }
    async componentWillMount(){
        let rs =await get('/api/hotcate');
        // console.log(rs);
        this.setState({
            datalist:rs.data.list
        })
    }
}

export default withRouter(HotCate)
   